layui.use(["form", "jquery"], function() {
    var form = layui.form;
    var $ = layui.jquery;
    lottie.loadAnimation({
        container: $("#animation")[0],
        path: "/asset/5056-delivery-latest.json",
        loop: true,
        render: "canvas",
        autoplay: true
    });
    $("#login").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "GET", //默认get
            url: "/user/login", //默认当前页
            data: form.val("loginForm"), //格式{key:value}
            dataType: "json",
            success: function(response) {
                if (response.code == 0) {
                    // layer.msg("登录成功");
                    location.href = "/sys/index";
                } else {
                    layer.msg(response.msg);
                }
                //请求成功回调
            },
            error: function(e) {
                //请求超时回调
                if (e.statusText == "timeout") {
                    layer.alert("请求超时");
                } else {
                    layer.alert("请求错误");
                }
            }
        });
    });

    $("#registerButton").click(function(e) {
        e.preventDefault();
        location.href = "/user/registerPage";
    });
});
